home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Libris Britannia 4
/
science library(b).zip
/
science library(b)
/
PROGRAMM
/
PROGEDIT
/
1023.ZIP
/
DIRLST.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1986-02-22
|
4KB
|
153 lines
procedure ListDir;
type
CharArray15 = array [1..55] of Char;
registers = record
AX,BX,CX,DX,BP,SI,DI,DS,ES,Flags : Integer;
end;
var
Regs : Registers;
DTA : array [1..43] of Byte;
Mask : CharArray15;
Fname,maskstr : String[55];
RtnCode,I,count : Integer;
driveltr,junk : char;
function ValidDrive(var dr : char): boolean;
begin
dr := Upcase(dr);
if not (dr in ['L','M','*','?']) then
begin
regs.ax := $3600;
regs.dx := (ord(dr)+1) - ord('A');
intr($21,regs);
if (regs.ax = $ffff) then
begin
ValidDrive := false;
writeln;
write(' Drive: '^G,dr,':, Invalid');clreol;
delay(1500);
end
else ValidDrive := true;
end else ValidDrive := true;
end;
procedure GetStatus(ch : char);
var
Tracks,TotalTracks,Drive,Bytes,
Sectors : Integer;
Used,TotalBytes : Real;
begin
ch := upcase(Ch);
if not(ch in ['L','*','?']) then drive := (ord(ch)+1) - ord('A') else drive := 0;
Regs.AX := $3600;
Regs.DX := Drive;
MSDos(Regs);
Tracks := Regs.BX;
TotalTracks := Regs.DX;
Bytes := Regs.CX;
Sectors := Regs.AX;
writeln; clreol;
Write( ' ' ); clreol;
if not(ch in ['L','*','?']) then
WriteLn(' Status of Drive ', chr(Drive + $40), ':')
else writeln(' Status of Logged Drive: ');
clreol;
Used := ((TotalTracks - Tracks) / TotalTracks) * 100;
Write(' ',Used:7:0, '% used.' ); clreol;
TotalBytes := ((Sectors * Bytes * 1.0) * Tracks);
WriteLn(' With ',TotalBytes:7:0,' Total Bytes Free.');clreol;
end;
procedure ConstrName(nax : integer);
begin
with regs do
begin
AX := nax;
DS := Seg(Mask);
DX := Ofs(Mask);
CX := 22;
MSDos(Regs);
RtnCode := AX and $FF;
end;
i := 1;
if (RtnCode = 0) then
repeat
Fname[i] := Chr(Mem[Seg(DTA):Ofs(DTA)+29+i]);
i := i + 1;
until not (Fname[i-1] in [' '..'~']) or (i>15);
end;
procedure GetMask;
begin
repeat
gotoxy(1,24);
write('Enter Mask: (ie A:\LETTER\*.TXT) ');clreol;
readln(maskstr);
driveltr := upcase(maskstr[1]);
until validdrive(driveltr);
end;
begin
count := 1;
RtnCode :=0;
FillChar(DTA,SizeOf(DTA),0);
FillChar(Mask,SizeOf(Mask),0);
FillChar(Fname,SizeOf(Fname),0);
with regs do
begin
AX := $1A00;
DS := Seg(DTA);
DX := Ofs(DTA);
end;
MSDos(Regs);
repeat
gotoxy(1,24);
write('List Directory: L(ogged directory, M(ask or drive (ie ''A'') ');clreol;
repeat
read(kbd,driveltr);
driveltr := upcase(driveltr);
until (driveltr in ['A'..'F','L','M'])
until (driveltr in ['A'..'F','L','M']) and (validdrive(driveltr));
if driveltr <> 'L'
then maskstr := driveltr + ':\????????.???'
else maskstr := '???????????.???';
if driveltr = 'M' then getmask;
for i := 1 to length(maskstr) do mask[i] := maskstr[i];
gotoxy(1,2);clreol;
if driveltr in['L','*','?'] then
writeln(' Directory of Logged Drive')
else writeln(' Directory of ',driveltr,': Drive');
ConstrName($4E00);
Fname[0] := Chr(i-1);
write(Fname:18);clreol;
while (RtnCode = 0) do
begin
ConstrName($4F00);
if count mod 4 = 0 then writeln;clreol;
if count mod 60 = 0 then
begin
writeln;clreol;
write('More - Press any key');
read(kbd,junk);
window(1,1,80,20);
clrscr;
gotoxy(1,2);
if driveltr in['L','*','?'] then
writeln(' Directory of Logged Drive')
else writeln(' Directory of ',driveltr,': Drive');
writeln;
window(1,1,80,25);
end;
count := count + 1;
Fname[0] := Chr(I-1);
if (RtnCode = 0) then Write(Fname:18); clreol;
end;
writeln;clreol;
getstatus(driveltr);
end;